import math


# 金融计数法，保留指定位数的有效数字
def format_number(number, decimal_places=4):
    assert isinstance(number, (int, float))
    if number < 1000:
        number = format(number, f".{decimal_places}")
    else:
        number = format(round(number, decimal_places), ",")
    return number
